// 写购物车页面发送的请求
import request from "../untils/request";

//获取购物车数据
export const getShop = (numType, type) => {
	return request("/api/front/cart/count?numType=true&type=sum")
}

//删除购物车数据
export const delShop = (ids) => {
	return request("/api/front/cart/delete", {
		ids: ids
	}, "post", {
		"Content-Type": "application/x-www-form-urlencoded",
		"Authori-zation": uni.getStorageSync("_token")
	})
}

//收藏数据
export const collectShop = (category, id) => {
	return request("/api/front/collect/all", {
		category: category,
		id: id
	}, "post")
}

//获取购物车分页
export const getShopCartPag = (isValid, limit, page) => {
	return request("/api/front/cart/list?page=1&limit=20&isValid=true")
}

//修改购物车状态
export const isShopCart = (id, number) => {
	return request("/api/front/cart/num", {
		id,
		number
	}, "post")
}

//购物车重选提交
export const cartChange = (id, num, productId, unique) => {
	return request("/api/front/cart/resetcart", {
		id,
		num,
		productId,
		unique
	}, "post")
}

//新增购物车
export const addCartShop = (cartNum, productId, productAttrUnique) => {
	return request("/api/front/cart/save", {
		cartNum,
		productId,
		productAttrUnique
	}, "post")
}

//获取默认收货地址
export const getDefaultAddress = (data) => {
	return request("/api/front/address/default", data)
}

//加载预下单订单号
export const getOrderId = (data) => {
	return request("/api/front/order/pre/order", data, "post")
}

//加载预下单
export const getOrderLoad = (preOrderNo) => {
	let url = "/api/front/order/load/pre/" + preOrderNo
	return request(url)
}

//订单详情
export const orderDetail = (orderId) => {
	let url = "/api/front/order/detail/" + orderId
	return request(url)
}

//订单列表
export const orderList = (data) => {
	return request("/api/front/order/list", data)
}

//创建订单
export const orderCreate = (data) => {
	return request("/api/front/order/create", data, "post")
}

//计算订单价格
export const orderPrice = (data) => {
	return request("/api/front/order/computed/price", data, "post")
}

//商品数量
export const shopNum = (data) => {
	return request("/api/front/cart/num", data, "post")
}
